Skip to contents

R CMD Check Test Coverage

F3MR is an R package that helps to analyze food microbiome omics data based on dedicated and curated metabolic modules derived from extensive literature reviews. It is part of the F3M software suite, developed by the INRAE Food Microbial Ecology lab.


Installation

You can install the development version of F3MR like so:

remotes::install_gitlab(
  repo = "fme_team/f3mr@main",
  host = "forge.inrae.fr"
)

Usage

1. Build Reference Database

The build_ref_db function constructs a reference database from functional annotations and GTDB classifications.

library(f3mr)
library(here)

# Paths to annotation files
funct_annotations_path <- here::here("data-raw/meat_ref_db/f3m_meat_genes_catalog_20241211_funct_annotations.tsv")
gtdb_classification_path <- here::here("data-raw/meat_ref_db/meat_genes_catalog_gtdb_classification.tsv")

# Build the reference database
meat_ref_db <- build_ref_db(
  funct_annotations_path = funct_annotations_path,
  gtdb_classification_path = gtdb_classification_path
)

# Access functional annotations
head(meat_ref_db$funct_annotations)

2. Import Single Sample Count Data

The import_sample_count function imports a single sample’s gene count data.

# Path to sample count file
sample_count_path <- here::here("data-raw/smfood/mRNA-SMF01-MAP-AB-T06_genes_abundancies_with_species_and_functions.tsv")

# Import sample count
sample_count <- import_sample_count(sample_count_path = sample_count_path)

# Preview sample count
head(sample_count)

3. Import Multiple Sample Count Files

The import_multiple_samples function imports and combines multiple sample count files from a folder.

# Path to the folder containing multiple sample files
folder_path <- here::here("data-raw/smfood")

# Import and combine sample counts
all_sample_counts <- import_multiple_samples(folder_path = folder_path)

# Preview combined sample counts
head(all_sample_counts)

4. Aggregate Counts

The aggregate_counts function aggregates gene counts at specified taxonomic and functional levels.

# Define aggregation levels
taxonomic_level <- "genus"
functional_level <- "food_microbiome_metabolic_function"

# Aggregate counts
aggregated_counts <- aggregate_counts(
  all_sample_counts = all_sample_counts,
  ref_db = meat_ref_db,
  taxonomic_level = taxonomic_level,
  functional_level = functional_level
)

# Preview aggregated counts
head(aggregated_counts)

5. Build Count Matrix

The build_count_matrix function converts aggregated data into a count matrix for downstream analyses like DESeq2.

# Build count matrix
count_matrix <- build_count_matrix(
  aggregated_counts = aggregated_counts,
  deseq2 = TRUE
)

# Preview count matrix
head(count_matrix)

Workflow Example

Below is an example workflow for analyzing metatranscriptomic data with F3MR:

# Step 1: Build reference database
meat_ref_db <- build_ref_db(funct_annotations_path, gtdb_classification_path)

# Step 2: Import multiple sample count files
all_sample_counts <- import_multiple_samples(folder_path)

# Step 3: Aggregate counts
aggregated_counts <- aggregate_counts(
  all_sample_counts = all_sample_counts,
  ref_db = meat_ref_db,
  taxonomic_level = "genus",
  functional_level = "food_microbiome_metabolic_function"
)

# Step 4: Build count matrix for downstream analysis
count_matrix <- build_count_matrix(aggregated_counts, deseq2 = TRUE)

# Step 5: Explore count matrix
head(count_matrix)

Package coverage

## f3mr Coverage: 71.55%

## R/build_count_matrix.R: 51.61%

## R/aggregate_counts.R: 60.53%

## R/build_ref_db.R: 85.71%

## R/import_sample_count.R: 93.75%

## R/import_multiple_samples.R: 100.00%

Contributing

We welcome contributions to improve F3MR. If you’d like to contribute, please open an issue or submit a pull request.


License

This project is licensed under the MIT License.